Repository navigation
Conversation
Use math.log1p and math.expm1 instead of naive 1 - (1 - x)**a so small multi-observable shot error rates do not cancel or underflow to zero.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace naive
1 - (1 - x)**aexpressions insinter.shot_error_rate_to_piece_error_ratewith-math.expm1(math.log1p(-x) * a)and guard0,1, andshot_error_rate == 0.5boundaries so small multi-observable error rates (e.g.,shot_error_rate=1e-12,pieces=100000,values=2) no longer cancel or underflow to0.0.Fixes #1150
Verification
/usr/local/google/home/pengfeichen/quantum_oss/checks/check_stim.sh:pytest(--ignoreplot/optional-decoder files,-k "not pymatching and not fusion_blossom and not mwpf") passed166 passed, 51 deselected(Python 3.13.18 / Linux).PYTHONPATH=glue/sample/src /usr/local/google/home/pengfeichen/quantum_oss/venvs/stim/bin/python dev/doctest_proper.py --module sinterpassed (0failures; updated the 3 docstring example literals that previously reflected float64 cancellation).